﻿using Microsoft.Web.WebView2.Core;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();



        }




        private  void Form1_LoadAsync(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;

            this.webView21.Source = new System.Uri("http://jcyj.guangyait.com/big_pc2/", System.UriKind.Absolute);
            this.webView21.TabIndex = 0;
            this.webView21.ZoomFactor = 1D;


       

            this.webView21.CoreWebView2InitializationCompleted += new System.EventHandler<Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs>(this.webView21_CoreWebView2InitializationCompleted);



        }

        private void webView21_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
        {

            //webview和js交互
            webView21.CoreWebView2.AddHostObjectToScript("webBrowserObj", new ScriptCallbackObject());
            webView21.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync("var webBrowserObj= window.chrome.webview.hostObjects.webBrowserObj;");


            //开启开发者工具
            //webView21.CoreWebView2.OpenDevToolsWindow();
            //禁止dev菜单
            //webView21.CoreWebView2.Settings.AreDevToolsEnabled = false;
            //禁止所有菜单
            //webView21.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;

        }



    }
}
